//
//  ByViewCardAndPayBig.m
//  chequanbao_ios
//
//  Created by mc on 2017/5/15.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByViewCardAndPayBig.h"
#import "ByBigImageViewController.h"
#define KMarginWidth 20

@implementation ByViewCardAndPayBig


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
    }
    
    return self;
}
-(void)setBigImg:(UIImage *)bigImg{
    _bigImg = bigImg;
    
    if (self.subviews) {
        for (UIView *view in self.subviews) {
            [view removeFromSuperview];
        }
    }
    if (_bigImg) {
        // 创建图片视图
//        CGFloat x, y, width, height;
//        width = SCREEN_WIDTH - 4 * KMarginWidth;
//        height = width;
//        x = 0;
//        y = 0;
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:
                                self.bounds];
        imgView.userInteractionEnabled = YES;
        imgView.tag = 100;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
                                       initWithTarget:self action:@selector(_pushToBigImgViewVC:)];
        [imgView addGestureRecognizer:tap];
            
            // 大图
        [self addSubview:imgView];
        [imgView setImage:_bigImg];

    }

}


- (void)_pushToBigImgViewVC:(UITapGestureRecognizer *)tap {
    
    ByBigImageViewController *vc = [[ByBigImageViewController alloc] init];
    vc.imageData = @[_bigImg];
    NSInteger index = tap.view.tag - 100;
    vc.indexPath = [NSIndexPath indexPathForItem:index inSection:0];
    
    [self.viewController presentViewController:vc animated:YES completion:nil];
}


@end
